package com.frxuexi.park2209.visitor

import com.frxuexi.base.mvvm.BaseViewModel
import com.frxuexi.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import javax.inject.Inject

@HiltViewModel
class VisitorViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {

    var visitorSuc = MutableStateFlow<String>("")
    var addVisitorSuc = MutableStateFlow<String>("")
    var delVisitorSuc = MutableStateFlow<String>("")

    fun getVisitors(map: Map<String,Int>){
        httpRequest({apiService.getVisitors(mapToBody(map))},{visitorSuc.value=it})
    }

    fun addVisitor(map: Map<String, Any>){
        httpRequest({apiService.addVisitor(mapToBody(map))},{addVisitorSuc.value=it})
    }

    fun delVisitor(map: Map<String, Int>){
        httpRequest({apiService.delVisitor(mapToBody(map))},{delVisitorSuc.value=it})
    }
}